package top.stmo.stmoBlog.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import top.stmo.stmoBlog.dao.pojo.Category;
import top.stmo.stmoBlog.dao.vo.ArtivleVo;
import top.stmo.stmoBlog.dao.vo.params.PageParams;
import top.stmo.stmoBlog.service.ArticleService;
import top.stmo.stmoBlog.service.CategoryService;
import java.util.List;

@Controller
public class ArticleController {

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ArticleService articleService;


    @GetMapping("article")
    public String article(PageParams pageParams,Model model) {

        List<Category> categoryList = categoryService.findAllCategory();

        List<ArtivleVo> artivleVoList = articleService.findAllArticle(pageParams);

        List<ArtivleVo> hotArtivleVoList = articleService.findHotArticle();

        model.addAttribute("hotArtivleVoList",hotArtivleVoList);

        model.addAttribute("total",pageParams.getTotal());

        model.addAttribute("artivleVoList",artivleVoList);

        model.addAttribute("categoryList",categoryList);

        model.addAttribute("pageParams",pageParams);

        return "article";
    }


}
